package com.cjh.mybatis02.session.defaults;

import com.cjh.mybatis02.bind.MapperRegistry;
import com.cjh.mybatis02.session.SqlSession;
import lombok.AllArgsConstructor;

/**
 * @Descripton
 * @Author cjh
 * @Date 2023/5/24 15:11
 */
@AllArgsConstructor
public class DefaultSqlSession implements SqlSession {
    /**
     * 映射器注册机
     */
    private MapperRegistry mapperRegistry;

    @Override
    public <T> T selectOne(String statement) {
        return (T) ("你被代理了"+statement);
    }

    @Override
    public <T> T selectOne(String statement, Object parameter) {
        return (T) ("被代理了"+"方法："+statement+"入参："+parameter);
    }

    @Override
    public <T> T getMapper(Class<T> type) {
        return mapperRegistry.getMapper(type, this) ;
    }
}
